package com.coupon.admin.dto;

import lombok.Data;

import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 优惠券创建DTO
 */
@Data
public class CouponCreateDTO {
    
    @NotBlank(message = "券名称不能为空")
    @Size(max = 100, message = "券名称长度不能超过100个字符")
    private String name;
    
    @NotBlank(message = "券类型不能为空")
    private String type;
    
    @NotNull(message = "面值不能为空")
    @DecimalMin(value = "0.01", message = "面值必须大于0")
    private BigDecimal value;
    
    @DecimalMin(value = "0.00", message = "使用门槛不能为负数")
    private BigDecimal threshold = BigDecimal.ZERO;
    
    @NotNull(message = "总库存不能为空")
    @Min(value = 1, message = "总库存必须大于0")
    @Max(value = 1000000, message = "总库存不能超过1000000")
    private Integer totalStock;
    
    @Min(value = 1, message = "每人限领数量必须大于0")
    @Max(value = 10, message = "每人限领数量不能超过10")
    private Integer perUserLimit = 1;
    
    @NotNull(message = "有效期开始时间不能为空")
    private LocalDateTime validStartTime;
    
    @NotNull(message = "有效期结束时间不能为空")
    private LocalDateTime validEndTime;
    
    @NotBlank(message = "适用范围不能为空")
    private String scope;
    
    private List<Long> scopeIds;
    
    @NotNull(message = "商家ID不能为空")
    private Long merchantId;
    
    private String description;
    
    private String usageInstructions;
    
    private Boolean supportGroup = false;
    
    @Min(value = 2, message = "拼券团人数至少2人")
    @Max(value = 5, message = "拼券团人数最多5人")
    private Integer groupSize = 2;
    
    @DecimalMin(value = "1.00", message = "奖励倍数必须大于等于1")
    @DecimalMax(value = "3.00", message = "奖励倍数不能超过3")
    private BigDecimal groupRewardMultiplier = BigDecimal.ONE;
    
    private Boolean supportBlindBox = false;
    
    private Long blindBoxTaskId;
    
    private String ladderConfig;
    
    @DecimalMin(value = "0.01", message = "AI推荐权重必须大于0")
    @DecimalMax(value = "2.00", message = "AI推荐权重不能超过2")
    private BigDecimal aiWeight = BigDecimal.ONE;
}

/**
 * 优惠券更新DTO
 */
@Data
class CouponUpdateDTO {
    
    @Size(max = 100, message = "券名称长度不能超过100个字符")
    private String name;
    
    @DecimalMin(value = "0.01", message = "面值必须大于0")
    private BigDecimal value;
    
    @DecimalMin(value = "0.00", message = "使用门槛不能为负数")
    private BigDecimal threshold;
    
    @Min(value = 1, message = "总库存必须大于0")
    @Max(value = 1000000, message = "总库存不能超过1000000")
    private Integer totalStock;
    
    @Min(value = 1, message = "每人限领数量必须大于0")
    @Max(value = 10, message = "每人限领数量不能超过10")
    private Integer perUserLimit;
    
    private LocalDateTime validStartTime;
    
    private LocalDateTime validEndTime;
    
    private String scope;
    
    private List<Long> scopeIds;
    
    private String description;
    
    private String usageInstructions;
    
    private Boolean supportGroup;
    
    @Min(value = 2, message = "拼券团人数至少2人")
    @Max(value = 5, message = "拼券团人数最多5人")
    private Integer groupSize;
    
    @DecimalMin(value = "1.00", message = "奖励倍数必须大于等于1")
    @DecimalMax(value = "3.00", message = "奖励倍数不能超过3")
    private BigDecimal groupRewardMultiplier;
    
    private Boolean supportBlindBox;
    
    private Long blindBoxTaskId;
    
    private String ladderConfig;
    
    @DecimalMin(value = "0.01", message = "AI推荐权重必须大于0")
    @DecimalMax(value = "2.00", message = "AI推荐权重不能超过2")
    private BigDecimal aiWeight;
}

/**
 * 优惠券查询DTO
 */
@Data
class CouponQueryDTO {
    
    private String name;
    
    private String type;
    
    private String status;
    
    private String scope;
    
    private Long merchantId;
    
    private LocalDateTime validStartTime;
    
    private LocalDateTime validEndTime;
    
    private Boolean supportGroup;
    
    private Boolean supportBlindBox;
}
